#!/bin/bash

cd /
image=$1

# check if directory exists
if [ ! -d $image ]
then
 echo "The directory $patchdir doesn't exist"
 echo "Please specify directory containing the patch files."
 exit 1
fi

image=$1


rpm -q bind 2>/dev/null
if [ $? -eq 0 ]
then
  rpm -Fvh $image/bind-9*rpm
else
  rpm -i $image/bind-9*rpm
fi
rpm -Fvh $image/bind-util*rpm
rpm -Fvh $image/glibc*rpm
rpm -Fvh $image/xinetd*rpm

cd /
tar -xf $image/hsc.tar

#lets update the version
#first lets see if the version already has the security fix indicator

grep "RHSA-2002:133-13" /opt/hsc/data/version
if [ "$?" -ne "0" ]
then
  echo "RHSA-2002:133-13" >> /opt/hsc/data/version
fi

grep "RHSA-2002:197-09" /opt/hsc/data/version
if [ "$?" -ne "0" ]
then
  echo "RHSA-2002:197-09" >> /opt/hsc/data/version
fi

grep "RHSA-2002:196-19" /opt/hsc/data/version
if [ "$?" -ne "0" ]
then
  echo "RHSA-2002:196-19" >> /opt/hsc/data/version
fi
exit 0

